package com.example.car

import android.os.Bundle
import android.view.Window
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.example.car.adapter.SubChannelAdapter
import com.example.car.bean.TitleInfo
import com.example.car.databinding.ActivitySubChannelhannelBinding

class SubChannelActivity : AppCompatActivity() {
    lateinit var binding: ActivitySubChannelhannelBinding
    var receivedList: MutableList<TitleInfo> = mutableListOf()
    private val subAdapter by lazy {
        SubChannelAdapter()
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivitySubChannelhannelBinding.inflate(layoutInflater)
        setContentView(binding.root)

        val window: Window = this@SubChannelActivity.window
        window.statusBarColor = ContextCompat.getColor(this@SubChannelActivity, R.color.black)

        // 获取传参数据
        receivedList = intent.getParcelableArrayListExtra<TitleInfo>("list")!!.toMutableList()
        // 数据关联
        subAdapter.differ.submitList(receivedList)
        binding.apply {
            // 返回
            toolbar.setOnClickListener {
                finish()
            }
            // adapter绑定
            recyclerView.adapter = subAdapter
        }
    }

}